//
//  UIButton+Extension.swift
//  微博三天
//
//  Created by jessica on 15/11/15.
//  Copyright © 2015年 jessica. All rights reserved.
//

import UIKit

extension UIButton {
    
    
    convenience init(title: String?,color: UIColor?,backImage : String?, image : String = "" , size : CGFloat = 14){
        
        self.init()
        //上面设置的时候要title: String?,判断的话都是要考虑可能为空的情况
//        setTitle(title, forState: .Normal)
        if title != nil {
        
        setTitle(title!, forState: .Normal)
        
        }
        
        if backImage != nil {
        setBackgroundImage(UIImage(named: backImage!), forState: .Normal)
        setBackgroundImage(UIImage(named: backImage! + "_highlighted"), forState: .Highlighted)
        }
        titleLabel?.font = UIFont.systemFontOfSize(size)
        setImage(UIImage(named: image), forState: .Normal)
        
        
        if color != nil {
            setTitleColor(color, forState: .Normal)
        }
        
    }
    
}